// 引入service
const demoService = require('../service/demoService')
const asyncUpload = require('../../../utils/uploadFileUtils');
const got = require('got');

const all = async (ctx, next) => {
    const response = await got('https://www.baidu.com');

    ctx.commonSuccessWithData(response.body);
}

const post = async (ctx, next) =>{
    let query = ctx.request.query;
    let body = ctx.request.body;
    ctx.commonSuccessWithData(await demoService.returnParam(body));
}

const upload = async (ctx, next) => {
    let file = ctx.request.files['file'];
    await asyncUpload("./files", file, [])
    ctx.commonSuccessWithoutData();
}


module.exports = {
    all,
    post,
    upload
}
